<!--$$$$$$$$$$$$$$$$$$ Mina Adel  , Gasser , Omar $$$$$$$$$$$$$$$$$$$ -->
<!--This checks whether the list of stories I receive is nil or not -->

<ul class="nav nav-tabs">	
  <li class="<%= 'active' if params[:action] == "get_main_feed" %>"><a href="<%= url_for :controller => "users", :action => "feed" %>">Main Feed</a></li>
  <li class="<%= 'active' if params[:action] == "get_hot_stories" %>"><a href="<%= url_for :controller => "users", :action => "hot" %>">Hot Stories</a></li>
  <li class="<%= 'active' if params[:action] == "get_top_rated" %>"><a href="<%= url_for :controller => "users", :action => "top" %>">Top Rated</a></li>
  <li class="<%= 'active' if params[:action] == "get_social_feed" %>"><a href="<%= url_for :controller => "users", :action => "social" %>">Social feed</a></li>
</ul>

<h2>Feeds</h2>
 <ul class="nav nav-list">
      <li class="divider"></li>
</ul>
<% unless @stories.nil? %>
	
	<% @stories.each do |f| %>
		<% if f.is_a?(Story) %>
			<%if f.interest.deleted.nil?%>
			<div id=<%=f.title%> class="well" style="border-right:5px solid #f89406;">
				<span  class="pull-right bluebadge" style="float-right"><%=f.interest.name%> </span>
				<br>
			<% if f.title.nil? %>
				<h3><%= link_to("Interest Feed, No Title", {:controller => 'stories', :action => 'get', :id => f.id} )%></h3>
					<%if f.media_link!=""%>
					<%= link_to image_tag(f.media_link),  {:controller => 'stories' , :action => 'get' , :id => f.id }%>
					<%end%>
				<table style="float:right">
					<tr>
						<td><span class="pull-right greenbadge">Ups(<%=f.liked.length%>)</span></td>
						<td><span class="pull-right redbadge">Downs(<%=f.disliked.length%>) </span></td>
					</tr>
				</table><br>
			<table>
				<span class="pull-right"><%= "Added "%><%= time_ago_in_words(f.created_at)%><%= " ago."%></span>
			</table>
				<% else %>
				<h4><%= link_to(f.title, {:controller => 'stories', :action => 'get', :id => f.id} )%></h4>
					<%if f.media_link!=""%>
					<%= link_to image_tag(f.media_link),  {:controller => 'stories' , :action => 'get' , :id => f.id }%>					
					<%end%>
                
                <table>
					<% people = f.sharers %>
					<% shares = Array.new %>
					<% count = 0 %>
					<% people.each do |person| %>
						<%if @friends.include?(person) %>
							<% shares << person %>
							<%count = count +1%>
						<%end%>
					<%end%>	
					<% unless shares.empty? %>
						<% user_name = shares.first.name  ||  shares.first.email.split('@')[0] %>	
						<% if count>1 %>	
						<td><h4><%=  user_name + " and "+(count-1).to_s + " other".pluralize(count-1) +" shared this"%></h4></td>
						<%else%>
						<td><h4><%=  user_name + " shared this"%></h4></td>
						<%end%>
					<%end%>
				</table>

				<table style="float:right">
					<tr>
						<td><span class="pull-right greenbadge">Ups(<%=f.liked.length%>)</span></td>
						<td><span class="pull-right redbadge">Downs(<%=f.disliked.length%>) </span></td>
					</tr>
					</table><br>
			<table>
				<span class="pull-right"><%= "Added "%><%= time_ago_in_words(f.created_at)%><%= " ago."%></span>
			</table>		
				<% end %>
				</div>
				<%end%>
			<% end %>
		</div>
		<% end %>
	
	<div class="apple_pagination">
		<%= will_paginate @stories, :container => false %>
	</div>
<% else %>
	<!--if nil, an error message of sorts appears -->
	<div id="Emptiness_Alert" class="story-component-box-mobile">
		There are no stories in your feed.
	</div>
<% end %>
<!--$$$$$$$$$$$$$$$$$$ Mina Adel $$$$$$$$$$$$$$$$$$$ -->
